Provides a delegate type to be used to process a macro.
public delegate string MacroSubsitutionDelegate(
T item,
string name,
object[] parameters
)
Public Delegate Function MacroSubsitutionDelegate(Of T)( _
ByVal item As T, _
ByVal name As String, _
ByVal ParamArray parameters() As Object _
) As String
generic<typename T>
public delegate String^ MacroSubsitutionDelegate(
_T^_ item,
String^ name,
... array<Object^>^ parameters
)
item
The user data passed to the macro process.
name
The name of the macro.
parameters
The parameters passed to the macro.
T
Type of user item being passed to the macro process.
A string that represents the macro.
This example adds two macros to the macro processor and processes a string.
using Leadtools.Dicom.Common.Anonymization;
public void MacroProcessorSample()
{
MacroProcessor<object> processor = new MacroProcessor<object>();
//
// add two macros to the macro processor
//
processor.Macros.Add("current_date", new MacroSubsitutionDelegate<object>(CurrentDateMacro));
processor.Macros.Add("current_time", new MacroSubsitutionDelegate<object>(CurrentTimeMacro));
//
// Process a macro string
//
Console.WriteLine(processor.Process(processor, "${current_date} ==> ${current_time}"));
}
private string CurrentDateMacro(object userData, string name, params object[] parameters)
{
return DateTime.Now.ToShortDateString();
}
private string CurrentTimeMacro(object userData, string name, params object[] parameters)
{
return DateTime.Now.ToShortTimeString();
}
Imports Leadtools.Dicom.Common.Anonymization
Public Sub MacroProcessorSample()
Dim processor As New MacroProcessor(Of Object)()
'
' add two macros to the macro processor
'
processor.Macros.Add("current_date", New MacroSubsitutionDelegate(Of Object)(AddressOf CurrentDateMacro))
processor.Macros.Add("current_time", New MacroSubsitutionDelegate(Of Object)(AddressOf CurrentTimeMacro))
'
' Process a macro string
'
Console.WriteLine(processor.Process(processor, "${current_date} ==> ${current_time}"))
End Sub
Private Function CurrentDateMacro(ByVal userData As Object, ByVal name As String, ByVal ParamArray parameters As Object()) As String
Return DateTime.Now.ToShortDateString()
End Function
Private Function CurrentTimeMacro(ByVal userData As Object, ByVal name As String, ByVal ParamArray parameters As Object()) As String
Return DateTime.Now.ToShortTimeString()
End Function
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET